home *** CD-ROM | disk | FTP | other *** search
Text File | 1994-06-26 | 2.6 KB | 156 lines | [TEXT/MPS ] |
- /*
- File: DocWindow.cp
-
- Contains: A simple document window
-
- Written by: Dave Falkenburg
-
- Copyright: © 1993-94 by Dave Falkenburg, all rights reserved.
-
- Change History (most recent first):
-
- To Do: Figure out what needs to move to TWindow
- */
-
- #include "DocWindow.h"
- #include "AppLib.h"
- #include <LowMem.h> // for LMGetCurApName()
-
- const short kScrollbarWidth = 15;
-
-
- TDocWindow::TDocWindow()
- {
- CreateWindow(kNormalWindow);
- }
-
- TDocWindow::~TDocWindow()
- {
- }
-
-
- WindowPtr
- TDocWindow::MakeNewWindow(WindowPtr behindWindow)
- {
- WindowPtr theNewWindow = GetNewWindow(128,nil,behindWindow);
- Str255 titleString;
- static long documentCount = 0;
-
- NumToString(documentCount++, titleString);
- SetWTitle(theNewWindow,titleString);
- ShowWindow(theNewWindow);
-
- return theNewWindow;
- }
-
-
- void
- TDocWindow::Activate(Boolean /* activating */)
- {
- DrawGrowIcon(fWindow);
- }
-
-
- void
- TDocWindow::AdjustCursor(EventRecord * /* anEvent */)
- {
- }
-
-
- void
- TDocWindow::Draw(void)
- {
- EraseRect(&fWindow->portRect);
-
- DrawGrowIcon(fWindow);
- }
-
-
- void
- TDocWindow::Click(EventRecord * /* anEvent */)
- {
- this->Select();
- }
-
- void
- TDocWindow::KeyDown(EventRecord * /* anEvent */)
- {
- this->Select();
- }
-
-
- void
- TDocWindow::AdjustForNewWindowSize(Rect *oldSize,Rect * /* newSize */)
- {
- Rect scrollbarRect;
-
- // Invalidate the old vertical scroll bar
-
- scrollbarRect.top = oldSize->top;
- scrollbarRect.left = oldSize->right - kScrollbarWidth;
- scrollbarRect.bottom = oldSize->bottom;
- scrollbarRect.right = oldSize->right;
- InvalRect(&scrollbarRect);
-
- // Invalidate the old horizontal scroll bar
-
- scrollbarRect.left = oldSize->left;
- scrollbarRect.top = oldSize->bottom - kScrollbarWidth;
- InvalRect(&scrollbarRect);
-
- DrawGrowIcon(fWindow);
- }
-
-
- Boolean
- TDocWindow::Close(void)
- {
- StandardCloseResult result;
- Str255 title;
-
- GetWTitle(this->fWindow,title);
- result = StandardCloseDocument(LMGetCurApName(),title,false,false);
-
- if (result != kCancelSaveDocument)
- {
- return TWindow::Close();
- }
- return false;
- }
-
-
- OSErr
- TDocWindow::HandleDrag(DragTrackingMessage dragMessage,DragReference theDrag)
- {
- RgnHandle hiliteRgn = NewRgn();
-
- switch (dragMessage)
- {
- case dragTrackingEnterWindow:
- SetRectRgn( hiliteRgn,
- fWindow->portRect.left,
- fWindow->portRect.top,
- fWindow->portRect.right-kScrollbarWidth,
- fWindow->portRect.bottom-kScrollbarWidth);
- ShowDragHilite(theDrag,hiliteRgn,true);
- break;
-
- case dragTrackingLeaveWindow:
- HideDragHilite(theDrag);
- break;
-
- default:
- break;
- }
-
- DisposeRgn(hiliteRgn);
- return(noErr);
- }
-
-
- OSErr
- TDocWindow::HandleDrop(DragReference /* theDrag */)
- {
- return(noErr);
- }
-